/**
 * 
 */
package ua.kpi.javatrainee6.model.curriculum;

import java.util.Arrays;

import ua.kpi.javatrainee6.model.people.*;
import ua.kpi.javatrainee6.model.utils.*;
import ua.kpi.javatrainee6.model.departments.*;

/**
 * Curriculum entity, contains array of SheduleActivities
 * implements Cloneable because Administrator have to give clone of
 * curriculum to users
 * Print curriculum for all university, specific teacher, group
 *
 */
public final class Curriculum implements Cloneable {
	
	private static final int SHEDULE_ACTIVITIES_NUMBER = 5;
	private SheduleActivity[] curriculum;
	
	/**
	 * Simple algorithm for creating curriculum,  All days are the same with the same group and professor
	 * will be changed in the next modules
	 */
	public Curriculum(Group group, Subject subject) {
		curriculum = new SheduleActivity[SHEDULE_ACTIVITIES_NUMBER];
		for (int i = 0; i < SHEDULE_ACTIVITIES_NUMBER; i++) {
			curriculum[i] = new SheduleActivity (group, subject, new Address(), 
					                             PairOfDay.FIRST_PAIR, DayOfWeek.MONDAY);  
		}
	}
	
	public Curriculum clone() {
		try {
			Curriculum cloned = (Curriculum) super.clone();
		    cloned.curriculum = (SheduleActivity[]) curriculum.clone();
		    return cloned;
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}
	
	/**
	 * Curriculum for all university
	 */
	public void printCurriculum() {
		for (SheduleActivity activity : curriculum) {
			System.out.println(activity);
		}
	}
	
	/**
	 * Curriculum for specific professor
	 * @param professor - specific professor
	 */
	public void printCurriculum(Professor professor) {
		for (SheduleActivity activity : curriculum) {
			if(professor.equals(activity.getProfessor())) {
				System.out.println(activity);
			}
		}
	}
	
	/**
	 * Curriculum for specific student
	 * @param student - specific student
	 */
	public void printCurriculum(Student student) {
		GroupInfo studentGroup = student.getGroup();
		printCurriculum(studentGroup);
		
	}
	
	/**
	 * Curriculum for specific group
	 * @param group - specific group
	 */
	public void printCurriculum(GroupInfo group) {
		for (SheduleActivity activity : curriculum) {
			if (group.equals(activity.getGroup())) {
				System.out.println(activity);
			}
		}
	}
	
	@Override
	public String toString() {
		return Arrays.toString(curriculum);
	}
}
